import * as THREE from "three";
import { OBJLoader } from "three/examples/jsm/loaders/OBJLoader";

export class mloader {
  constructor(data: any, callback: Function) {
    function onProgress(xhr) {
      if (xhr.lengthComputable) {
        const percentComplete = (xhr.loaded / xhr.total) * 100;
        console.log("model " + Math.round(percentComplete) + "% downloaded");
      }
    }

    function onError(error) {
      console.log("load failed", error);
    }

    const loader = new OBJLoader(THREE.DefaultLoadingManager);
    loader.load(
      data,
      function (obj) {
        callback(obj);
      },
      onProgress,
      onError
    );
  }
}
